<?php

namespace app\common\middleware;

use liketp\contract\MiddlewareOnion;
use liketp\Request;
use liketp\Response;

class AuthTest extends MiddlewareOnion
{
    public function handle(callable $next, Request $req, ?array $args = []): Response
    {
        dump('AuthTest before');
        $res = $next($req);
        dump('AuthTest after');
        return $res;
    }

    public function method($next, $req, $args)
    {
        $req .= ' authtest';
        $res = $next($req);
        dump($args);
        $res .= ' authtest';
        return $res;
    }
    public function before($req, $args)
    {
        $req .= ' authtest';
        dump('auth test before', $args);
        return $req;
    }

    public function after($res, $args)
    {
        $res .= ' authtest';
        dump('auth test after', $args);
        return $res;
    }
}
